export const MaintenanceMan = {
  data() {
    return {
      name: '', // 1.姓名
      sex: '', // 2.性别
      cardType: '', // 3.证件类型：身份证
      idCard: '', // 4.身份证号
      mobile: '', // 5.电话号码
      education: '', // 6.学历
      techGrade: '', // 7.技能等级证
      isTechnicians: '', // 8.是否是技术人员
      major: '', // 9.专业类型
      title: '', // 10.技术职称
      isOperator: '', // 11.是否操作员
      OperatorPQCert: '', // 12.职业资格证书
      OperatorTQCert: '', // 13.技术资格证书
      workBeginDate: '', // 14.维保开始日期
      isBuyInsurance: '', // 15。购买保险
      START_ROW_NUM: 3,
      errInfoArray: []
    }
  },
  methods: {
    checkValue(str, strings) {
      let flag = false
      if (str.isEmpty()) {
        flag = false
        return flag
      }

      for (var i = 0; i < strings.length; i++) {
        if (str === strings[i]) { //
          flag = true
          break
        }
      }
      return flag
    },
    getErrInfo(i, j, info, type) {
      let s = ''
      if (type === 0) { s = '第' + i + '行,' + '第' + j + '列，存在错误！只能为:' + info }
      if (type === 1) { s = '第' + i + '行,' + '第' + j + '列，存在错误！格式不正确:' + info }
      if (type === 2) { s = '第' + i + '行,' + '存在错误！关联数据不正确:' + info }
      return s
    },
    getErrInfoArray() {
      return this.errInfoArray
    },
    stringsToStr(strings) {
      let s = '['
      for (var i = 0; i < strings.length; i++) { s = s + strings[i] + ',' }
      s = s.substring(0, s.length() - 1)
      s = s + ']'
      return s
    },
    checkField(rowIndex, colIndex, value) {
      const sexStrings = '男, 女' // 2.
      const cardTypeStrings = '身份证' // 3.证件类型

      const educationStrings = '初中,中专,高中,大专,本科,硕士,博士' // 6.学历
      const techGradeStrings = '五级,四级,三级,二级,一级' // 7.技术等级

      const isTechniciansStrings = '是, 否' // 8.
      const majorStrings = 'T1, T2, T3, A4' // 9.专业
      const titleStrings = '初级,中级,高级,技工,高级技工' // 10.技术职称

      const isOperatorStrings = '是, 否' // 11.
      const OperatorPQCertStrings = '初级,中级,高级,技工,高级技工' // 12.职业资格证书
      const OperatorTQCertStrings = '电梯修理, 维护保养' // 13.技术资格证书

      const isBuyInsuranceStrings = '是, 否' // 购买保险

      switch (colIndex) { //* ***增加了一列****
        case 3 : { // 性别
          if (this.checkValue(value.empty1, sexStrings) === false) { this.errInfoArray.push(this.getErrInfo(rowIndex, colIndex, this.stringsToStr(sexStrings), 0)) }
          break
        }
        case 4 : { // 身份证
          if (this.checkValue(value.empty2, cardTypeStrings) === false) { this.errInfoArray.push(this.getErrInfo(rowIndex, colIndex, this.stringsToStr(cardTypeStrings), 0)) }
          break
        }
        case 5 : { // 身份证号码
          // if (input.isIDCard(value.empty3) === false) { this.errInfoArray.push(this.getErrInfo(rowIndex, colIndex, value, 1)) }
          break
        }
        case 6 : { // 手机号
          // if (input.isMobile(value.empty4) === false) { this.errInfoArray.push(this.getErrInfo(rowIndex, colIndex, value, 1)) }
          break
        }
        case 7 : { // 学历
          if (this.checkValue(value.empty5, educationStrings) === false) { this.errInfoArray.push(this.getErrInfo(rowIndex, colIndex, this.stringsToStr(educationStrings), 0)) }
          break
        }
        case 8 : { // 技术等级
          if (this.checkValue(value.empty6, techGradeStrings) === false) { this.errInfoArray.push(this.getErrInfo(rowIndex, colIndex, this.stringsToStr(techGradeStrings), 0)) }
          break
        }
        case 9 : { // 是否专业技术人员
          if (this.checkValue(value.empty7, isTechniciansStrings) === false) { this.errInfoArray.push(this.getErrInfo(rowIndex, colIndex, this.stringsToStr(isTechniciansStrings), 0)) }
          break
        }
        case 10 : { // 专业
          if (this.checkValue(value.empty8, majorStrings) === false) { this.errInfoArray.push(this.getErrInfo(rowIndex, colIndex, this.stringsToStr(majorStrings), 0)) }
          break
        }
        case 11 : { // 技术职称
          if (this.checkValue(value.empty9, titleStrings) === false) { this.errInfoArray.push(this.getErrInfo(rowIndex, colIndex, this.stringsToStr(titleStrings), 0)) }
          break
        }
        case 12 : { // 是否作业人员
          if (this.checkValue(value.empty10, isOperatorStrings) === false) { this.errInfoArray.push(this.getErrInfo(rowIndex, colIndex, this.stringsToStr(isOperatorStrings), 0)) }
          break
        }
        case 13 : { // 职业资格证书
          if (this.checkValue(value.empty11, OperatorPQCertStrings) === false) { this.errInfoArray.push(this.getErrInfo(rowIndex, colIndex, this.stringsToStr(OperatorPQCertStrings), 0)) }
          break
        }
        case 14 : { // 技术资格证书
          if (this.checkValue(value.empty12, OperatorTQCertStrings) === false) { this.errInfoArray.push(this.getErrInfo(rowIndex, colIndex, this.stringsToStr(OperatorTQCertStrings), 0)) }
          break
        }
        case 15 : { // 参保工作日
          // if (input.isDateTime(value.empty13) === false) { this.errInfoArray.push(this.getErrInfo(rowIndex, colIndex, value, 1)) }
          break
        }
        case 16 : { // 购买保险
          if (this.checkValue(value.empty14, isBuyInsuranceStrings) === false) { this.errInfoArray.push(this.getErrInfo(rowIndex, colIndex, this.stringsToStr(isBuyInsuranceStrings), 0)) }
          break
        }
      }
    },
    checkRow(row, rowIndex) {
      // System.out.println(row.toString());
      // if ((!row.get(6).equals('是')) && (!row.get(10).equals('是'))) {
      //   this.errInfoArray.push(this.getErrInfo(rowIndex, 0, '是否是技术人员和作业人员必须二选一。', 2))
      // }

      // if (row.get(6).equals('是')) {
      //   if ((row.get(7).isEmpty()) || (row.get(8).isEmpty())) {
      //     this.errInfoArray.push(this.getErrInfo(rowIndex, 0, '技术人员为“是”后面两项必填', 2))
      //   }
      // }

      // if (row.get(10).equals('是')) {
      //   if ((row.get(11).isEmpty()) || (row.get(12).isEmpty())) {
      //     this.errInfoArray.push(this.getErrInfo(rowIndex, 0, '操作人员为“是”后面两项必填', 2))
      //   }
      // }
    }
  }
}

export default MaintenanceMan
